/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package umled.gui;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import umled.view.UMLPanel;
import umled.model.*;
/**
 *
 * @author ANor
 */
public class UMLFrame extends JFrame{
    JMenuBar menuBar = new JMenuBar();
    UMLPanel panel;
    public UMLFrame(){
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds( 0, 0, d.width, d.height );
        
        //Creating of MenuBar
        //TODO add ActionListeners for all JMenuItems
        
        //Creating of File Menu
        JMenu file = new JMenu( "File" );
        JMenuItem newProject = new JMenuItem( "New" );
        JMenuItem openProject = new JMenuItem( "Open" );
        JMenuItem saveProject = new JMenuItem( "Save" );
        JMenuItem saveProjectAs = new JMenuItem( "Save as..." );
        JMenuItem exit = new JMenuItem( "Exit" );
        exit.addActionListener( new ActionListener(){
            public void actionPerformed( ActionEvent e ){
                System.exit( 0 );
            }
        });
        file.add( newProject );
        file.addSeparator();
        file.add( openProject );
        file.addSeparator();
        file.add( saveProject );
        file.add( saveProjectAs );
        file.addSeparator();
        file.add(exit);
        menuBar.add( file );
        
        //Creating of Edit Menu
        JMenu edit = new JMenu( "Edit" );
        JMenuItem undo = new JMenuItem( "Undo" );
        JMenuItem redo = new JMenuItem( "Redo" );
        JMenuItem cut = new JMenuItem( "Cut" );
        JMenuItem copy = new JMenuItem( "Copy" );
        JMenuItem paste = new JMenuItem( "Paste" );
        edit.add( undo );
        edit.add( redo );
        edit.addSeparator();
        edit.add( cut );
        edit.add( copy );
        edit.add( paste );
        menuBar.add(edit);
        
        //Creating of Build Menu
        JMenu build = new JMenu( "Build" );
        JMenuItem buildProject = new JMenuItem( "Build project" );
        buildProject.addActionListener( new ActionListener(){
            public void actionPerformed( ActionEvent event ){
                
            }
        });
        JMenu setLanguage = new JMenu( "Set language..." );
        ButtonGroup languages = new ButtonGroup();
        JRadioButtonMenuItem java = new JRadioButtonMenuItem( "Java" );
        java.setSelected( true );
        JRadioButtonMenuItem cpp = new JRadioButtonMenuItem( "C++" );
        languages.add( java );
        languages.add( cpp );
        setLanguage.add( java );
        setLanguage.add( cpp );
        build.add( buildProject );
        build.add( setLanguage );
        menuBar.add( build );
        
        //Creating of Help Menu
        JMenu help = new JMenu( "Help" );
        JMenuItem about = new JMenuItem( "About" );
        help.add( about );
        menuBar.add( help );
        
        setJMenuBar( menuBar );
        //End of creating of MenuBar
        
        //Initializing of view of model (Test)
        UMLModel model = new UMLModel( "Untitled", 0 , 0, getWidth(), getHeight());
        model.addType( new UMLClass( "SomeClass", model, 20, 20, 40, 60, UMLVisible.PUBLIC));
        panel = new UMLPanel( model );
        setTitle( "Simple UML editor: " + model.getName());
    }    
    
    public static void main1(String[] args){
        JFrame f = new UMLFrame();
        f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        f.setVisible( true );
    }
}
